package com.huika.dealontop.control.nearby.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.huika.dealontop.R;
import com.huika.dealontop.control.base.BaseAda;
import com.huika.dealontop.support.domain.FilterBean;
import com.huika.dealontop.views.ToastMsg;

import java.util.ArrayList;
import java.util.List;

/**
 * 分类筛选节点适配器
 */
public class NearbyFilterAdapter extends BaseAda<FilterBean> {
    ViewHolder vh = null;
    FilterBean filterBean;

    public NearbyFilterAdapter(Context context) {
        super(context);
    }


    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        if (view == null) {
            view = mInflater.inflate(R.layout.item_neayby_filter, viewGroup, false);
            vh = new ViewHolder(view);
            //只做一次初始化就可以了
            vh.general_loy.setBackgroundResource(R.drawable.common_hover);
            view.setTag(vh);
        } else {
            vh = (ViewHolder) view.getTag();
        }
        filterBean = getItem(i);
        String name = filterBean.getFilter_Name();
        vh.tv_name.setText(name);

        vh.checkBox.setBackgroundResource(filterBean.isSelete
                ? R.mipmap.common_select_choise_icon
                : R.mipmap.common_unselect_choise_icon);

        return view;
    }

    class ViewHolder {
        public TextView tv_name;
        public ImageView checkBox;
        public RelativeLayout general_loy;

        public ViewHolder(View view) {
            tv_name = (TextView) view.findViewById(R.id.name);
            checkBox = (ImageView) view.findViewById(R.id.num_cbs);
            general_loy = (RelativeLayout) view.findViewById(R.id.general_loy);
        }
    }
}
